//
//  XieYiViewController.m
//  TQY
//
//  Created by 甘世清 on 2024/8/23.
//

#import "XieYiViewController.h"
#import "XieYiTableViewCell.h"
@interface XieYiViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation XieYiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.zx_navTitle = SQNSLocalString(@"协议");
    // Do any additional setup after loading the view.
}

- (void)SQ_UIViewForSelfView{
    UIImageView * bgImageView = [[UIImageView alloc]init];
    bgImageView.image = SQGetImage(@"二级背景");
    bgImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.view addSubview:bgImageView];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    [self.jsonArray addObject:@"用户协议"];
    [self.jsonArray addObject:@"隐私协议"];
    [self.jsonArray addObject:@"自动续费与增值服务协议"];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self.view);
        make.top.equalTo(self.zx_navBar.mas_bottom);
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
     return self.jsonArray.count;
}
 
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    XieYiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"XieYiTableViewCell"];
    if (!cell) {
        cell = [[XieYiTableViewCell alloc] initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:@"XieYiTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.messageLabel.text = [self.jsonArray objectAtIndex:indexPath.item];
    return cell;
}
 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 58;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString * yonghu = [self.jsonArray objectAtIndex:indexPath.item];
    CommonWebVcView * vc  =[[CommonWebVcView alloc]init];
    if ([yonghu isEqualToString:@"用户协议"]) {
        vc.urlStr = @"https://taoqingyan.qingtao.fun/agreement.html?id=1";
    } else   if ([yonghu isEqualToString:@"隐私协议"]) {
        vc.urlStr = @"https://taoqingyan.qingtao.fun/agreement.html?id=2";
    }else {
        vc.urlStr = @"https://taoqingyan.qingtao.fun/agreement.html?id=3";
    }
    //
    [self SQ_pushViewControllerFull:vc];
    
}

@end
